﻿Imports System.Data.SqlClient
Imports System.Configuration
Imports BEGestionProyecto
Public Class DLGPGastoRegistro
#Region "Consultar"
    'Funcion que carga la Lista de Categorias del Personal
    'fecha crea         fecha modifica         autor
    '01/02/2012         01/02/2012              JKP
    Public Function fuDLListarGastoRegistroxFechas(ByVal piPepPersonalID As Integer, ByVal pfGasFechRegGastoI As Date, ByVal pfGasFechRegGastoF As Date) As DataTable
        Try

            Dim lCnx As New SqlConnection(ConfigurationManager.ConnectionStrings("GPConnectionString").ConnectionString)
            Dim lCmd As New SqlCommand("paGPGastoRegistroxFechasLST", lCnx)
            lCmd.CommandType = CommandType.StoredProcedure
            lCmd.Parameters.Add("@pepPersonalID", SqlDbType.VarChar).Value = piPepPersonalID
            lCmd.Parameters.Add("@gasFechRegGastoI", SqlDbType.SmallDateTime).Value = pfGasFechRegGastoI
            lCmd.Parameters.Add("@gasFechRegGastoF", SqlDbType.SmallDateTime).Value = pfGasFechRegGastoF

            Dim lDa As New SqlDataAdapter
            lDa.SelectCommand = lCmd
            'Llenar Dataset
            Dim lDs As New DataSet
            lDa.Fill(lDs)
            'Retornar Datos
            Return lDs.Tables(0)
        Catch ex As Exception
            Throw New ArgumentException("Descripcion : " & ex.Message)
            Return Nothing
        End Try
    End Function

    'Funcion que carga la Lista de Categorias del Personal
    'fecha crea         fecha modifica         autor
    '01/02/2012         01/02/2012              JKP
    Public Function fuDLBuscarGastoRegistrox(ByVal piGasGastoID As Integer) As DataTable
        Try

            Dim lCnx As New SqlConnection(ConfigurationManager.ConnectionStrings("GPConnectionString").ConnectionString)
            Dim lCmd As New SqlCommand("paGPGastoRegistroBUSx", lCnx)
            lCmd.CommandType = CommandType.StoredProcedure
            lCmd.Parameters.Add("@gasGastoID", SqlDbType.Int).Value = piGasGastoID

            Dim lDa As New SqlDataAdapter
            lDa.SelectCommand = lCmd
            'Llenar Dataset
            Dim lDs As New DataSet
            lDa.Fill(lDs)
            'Retornar Datos
            Return lDs.Tables(0)
        Catch ex As Exception
            Throw New ArgumentException("Descripcion : " & ex.Message)
            Return Nothing
        End Try
    End Function

    Public Function fuDLListarActividadPendxPersonaGasto(ByVal pgascodPersona As String) As DataTable
        Try

            Dim lCnx As New SqlConnection(ConfigurationManager.ConnectionStrings("GPConnectionString").ConnectionString)
            Dim lCmd As New SqlCommand("paGPActividadPendxPersonaGastoLST", lCnx)
            lCmd.CommandType = CommandType.StoredProcedure
            lCmd.Parameters.Add("@horcodPersona", SqlDbType.VarChar).Value = pgascodPersona
            Dim lDa As New SqlDataAdapter
            lDa.SelectCommand = lCmd
            'Llenar Dataset
            Dim lDs As New DataSet
            lDa.Fill(lDs)
            'Retornar Datos
            Return lDs.Tables(0)
        Catch ex As Exception
            Throw New ArgumentException("Descripcion : " & ex.Message)
            Return Nothing
        End Try
    End Function


#End Region
#Region "Actualizar"
    'Funcion que carga la Lista de Categorias del Personal
    'fecha crea         fecha modifica         autor
    '01/02/2012         01/02/2012              JKP
    Public Function fuDLInsertarGastoRegistro(ByVal pBE As BEGPGastoRegistro) As Boolean
        Try
            'Se crea una variable sqlconnection
            Dim lCnx As New SqlConnection(ConfigurationManager.ConnectionStrings("GPConnectionString").ConnectionString)
            'Se crea un sqlcommand
            Dim lCmd As New SqlCommand
            'Se crea la conexion para el command
            lCmd.Connection = lCnx
            'Se declara el typo de comando
            lCmd.CommandType = CommandType.StoredProcedure
            'Declaras el nombre del Store Procedure de Insertar Empleado
            lCmd.CommandText = "paGPGastoRegistroINS"
            'Definicion de Parametros para el procedure
            With lCmd.Parameters
                .Add(New SqlParameter("@gasFechRegGasto", SqlDbType.Date)).Value = pBE.GasFechRegGasto
                .Add(New SqlParameter("@gasDescMotivo", SqlDbType.VarChar)).Value = pBE.GasDescMotivo
                .Add(New SqlParameter("@gasobsGasto", SqlDbType.VarChar)).Value = pBE.GasobsGasto
                .Add(New SqlParameter("@gasImporteGasto", SqlDbType.Decimal)).Value = pBE.GasImporteGasto
                .Add(New SqlParameter("@gasTipoMoneda", SqlDbType.SmallInt)).Value = pBE.GasTipoMoneda
                .Add(New SqlParameter("@gasUserCreacionID", SqlDbType.Int)).Value = pBE.GasUserCreacionID
                .Add(New SqlParameter("@gasPersonalProyectoID", SqlDbType.Int)).Value = pBE.GasPersonalProyectoID

            End With
            'Se cargan los parametros que viene de las entidades guardadas temporalmente
            'lCmd.Parameters("@prycodProyecto").Value = pBE.prycodProyecto
            'lCmd.Parameters("@prycodLos").Value = pBE.prycodLos
            lCnx.Open()
            lCmd.ExecuteNonQuery()
            lCnx.Close()
            Return True
        Catch ex As Exception
            Throw New ArgumentException("Descripcion : " & ex.Message)
            Return False
        End Try
    End Function
    'Funcion que carga la Lista de Categorias del Personal
    'fecha crea         fecha modifica         autor
    '01/02/2012         01/02/2012              JKP
    Public Function fuDLActualizarGastoRegistro(ByVal pBE As BEGPGastoRegistro) As Boolean
        Try
            'Se crea una variable sqlconnection
            Dim lCnx As New SqlConnection(ConfigurationManager.ConnectionStrings("GPConnectionString").ConnectionString)
            'Se crea un sqlcommand
            Dim lCmd As New SqlCommand
            'Se crea la conexion para el command
            lCmd.Connection = lCnx
            'Se declara el typo de comando
            lCmd.CommandType = CommandType.StoredProcedure
            'Declaras el nombre del Store Procedure de Insertar Empleado
            lCmd.CommandText = "paGPGastoRegistroUPD"
            'Definicion de Parametros para el procedure
            With lCmd.Parameters
                .Add(New SqlParameter("@gasGastoID", SqlDbType.Int)).Value = pBE.GasGastoID
                .Add(New SqlParameter("@gasFechRegGasto", SqlDbType.Date)).Value = pBE.GasFechRegGasto
                .Add(New SqlParameter("@gasDescMotivo", SqlDbType.VarChar)).Value = pBE.GasDescMotivo
                .Add(New SqlParameter("@gasobsGasto", SqlDbType.VarChar)).Value = pBE.GasObsGasto
                .Add(New SqlParameter("@gasImporteGasto", SqlDbType.Decimal)).Value = pBE.GasImporteGasto
                .Add(New SqlParameter("@gasTipoMoneda", SqlDbType.SmallInt)).Value = pBE.GasTipoMoneda
                .Add(New SqlParameter("@gasUserCreacionID", SqlDbType.Int)).Value = pBE.GasUserCreacionID
                .Add(New SqlParameter("@gasPersonalProyectoID", SqlDbType.Int)).Value = pBE.GasPersonalProyectoID

            End With
            'Se cargan los parametros que viene de las entidades guardadas temporalmente
            lCnx.Open()
            lCmd.ExecuteNonQuery()
            lCnx.Close()
            Return True
        Catch ex As Exception
            Throw New ArgumentException("Descripcion : " & ex.Message)
            Return False
        End Try
    End Function


    'Funcion que carga la Lista de Categorias del Personal
    'fecha crea         fecha modifica         autor
    '01/02/2012         01/02/2012              JKP
    Public Function fuDLEliminarGastoRegistro(ByVal piGasGastoID As Integer, ByVal piGascodUserModifica As Integer) As Boolean
        Try
            'Se crea una variable sqlconnection
            Dim lCnx As New SqlConnection(ConfigurationManager.ConnectionStrings("GPConnectionString").ConnectionString)
            'Se crea un sqlcommand
            Dim lCmd As New SqlCommand
            'Se crea la conexion para el command
            lCmd.Connection = lCnx
            'Se declara el typo de comando
            lCmd.CommandType = CommandType.StoredProcedure
            'Declaras el nombre del Store Procedure de Insertar Empleado
            lCmd.CommandText = "paGPGastoRegistroDEL"
            'Definicion de Parametros para el procedure
            With lCmd.Parameters
                .Add(New SqlParameter("@gasGastoID", SqlDbType.Int)).Value = piGasGastoID
                .Add(New SqlParameter("@gascodUserModifica", SqlDbType.Int)).Value = piGascodUserModifica
            End With
            'Se cargan los parametros que viene de las entidades guardadas temporalmente

            lCnx.Open()
            lCmd.ExecuteNonQuery()
            lCnx.Close()
            Return True
        Catch ex As Exception
            Throw New ArgumentException("Descripcion : " & ex.Message)
            Return False
        End Try
    End Function
#End Region


    Public Function fuDLListarProyectoxPersona(ByVal piPepPersonalID As Integer) As DataTable
        Try

            Dim lCnx As New SqlConnection(ConfigurationManager.ConnectionStrings("GPConnectionString").ConnectionString)
            Dim lCmd As New SqlCommand("paGPProyectoPersonaLST", lCnx)
            lCmd.CommandType = CommandType.StoredProcedure
            lCmd.Parameters.Add("@pepPersonalID", SqlDbType.Int).Value = piPepPersonalID

            Dim lDa As New SqlDataAdapter
            lDa.SelectCommand = lCmd
            'Llenar Dataset
            Dim lDs As New DataSet
            lDa.Fill(lDs)
            'Retornar Datos
            Return lDs.Tables(0)
        Catch ex As Exception
            Throw New ArgumentException("Descripcion : " & ex.Message)
            Return Nothing
        End Try
    End Function

End Class

